<?php

namespace App\Policies\Admin;

use App\Models\Examination;
use App\Models\Role;
use App\Models\User;
use Illuminate\Auth\Access\HandlesAuthorization;

class ExaminationPolicy
{
    use HandlesAuthorization;

    /**
     *
     * @param User $user
     */
    public function before(User $user)
    {
        return $user->hasRole(Role::SUPER_ADMIN);
    }

    /**
     * 详情策略
     *
     * @param User $user
     * @param Examination $examination
     * @return mixed
     */
    public function view(User $user, Examination $examination)
    {

        return $user->id === $examination->user_id;
    }

    /**
     * 修改策略
     * @param User $user
     * @param Examination $examination
     * @return bool
     */
    public function update(User $user, Examination $examination)
    {
        return $user->id === $examination->user_id;
    }

    /**
     * 删除策略
     *
     * @param User $user
     * @param Examination $examination
     * @return mixed
     */
    public function delete(User $user, Examination $examination)
    {
        return $user->id === $examination->user_id;
    }
}
